Skip to content

Conversation

hectormmg
Copy link
Member

@hectormmg hectormmg commented Jun 5, 2025

Turns the following into standalone exported functions to help minify them on build output:

  1. BaseInteractionClient:
    • getRedirectUri()
    • getDiscoveredAuthority
    • initializeServerTelemetryManager()
  2. StandardInteractionClient:
    • InitializeAuthorizationRequest()
  3. PopupClient:
    • monitorPopupForHash()
    • cleanPopup()

@github-actions github-actions bot added the msal-browser Related to msal-browser package label Jun 5, 2025
@hectormmg hectormmg requested a review from a team as a code owner June 16, 2025 20:50
@github-actions github-actions bot added the msal-node Related to msal-node package label Jun 16, 2025
@github-actions github-actions bot removed the msal-node Related to msal-node package label Jun 16, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Jul 7, 2025
@Copilot Copilot AI review requested due to automatic review settings August 7, 2025 20:55
@hectormmg hectormmg dismissed stale reviews from peterzenz, shylasummers, and tnorling via 2e779b3 August 7, 2025 20:55
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs: Attention 👋 Awaiting response from the MSAL.js team label Aug 7, 2025
Copilot

This comment was marked as outdated.

@hectormmg hectormmg requested a review from Copilot August 7, 2025 21:25
Copilot

This comment was marked as outdated.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors several methods from the BaseInteractionClient and StandardInteractionClient classes into standalone exported functions to enable better code minification during build output. The refactoring focuses on improving bundle size optimization while maintaining the same functionality.

Key changes:

  • Extracted getRedirectUri, getDiscoveredAuthority, initializeServerTelemetryManager, and clearCacheOnLogout from BaseInteractionClient as standalone functions
  • Moved initializeAuthorizationRequest from StandardInteractionClient to a standalone function
  • Created PopupUtils module with monitorPopupForHash and cleanPopup functions extracted from PopupClient
  • Updated all test files to use the new standalone functions instead of class methods

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/interaction_client/BaseInteractionClient.ts Converts protected methods to standalone exported functions with proper parameter passing
src/interaction_client/StandardInteractionClient.ts Extracts initializeAuthorizationRequest as standalone function and updates calls to use new BaseInteractionClient functions
src/utils/PopupUtils.ts New utility file containing popup monitoring and cleanup functions extracted from PopupClient
src/interaction_client/PopupClient.ts Removes monitorPopupForHash and cleanPopup methods, updates calls to use PopupUtils functions
Multiple client files Updates all interaction clients to use new standalone functions with proper parameter passing
Multiple test files Updates test spies and mocks to reference new standalone functions instead of class methods
change/@azure-msal-browser-*.json Beachball changefile documenting the patch-level change

@hectormmg hectormmg enabled auto-merge (squash) August 11, 2025 19:16
Comment on lines +98 to +99
clientConfig?: BrowserConfiguration,
logger?: Logger
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these things should be required params. I can't think of a scenario where these would be expected to be undefined

clientId: string,
correlationId: string,
browserStorage: BrowserCacheManager,
logger?: Logger,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be required

* @returns Promise that resolves to a discovered Authority instance
*/
export async function getDiscoveredAuthority(
params: {
requestAuthority?: string;
requestAzureCloudOptions?: AzureCloudOptions;
requestExtraQueryParameters?: StringDict;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope for this PR but in light of recent conversations around EQP let's consider accepting instanceAware here instead of the whole object and have a separate helper we can use to get the correct value. Can we put something on the backlog?

* @returns Promise that resolves to a discovered Authority instance
*/
export async function getDiscoveredAuthority(
params: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a good idea to flatten this map as well

Copy link
Collaborator

@tnorling tnorling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits/observations but nothing blocking atm

@hectormmg hectormmg merged commit e4278b9 into msal-v5 Aug 12, 2025
6 of 7 checks passed
@hectormmg hectormmg deleted the standalone-functions branch August 12, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
msal-browser Related to msal-browser package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants